﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace LilTmSim
{
	public class EndPointConverter : IMultiValueConverter
	{
		public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (values[0] is Point && values[1] is Point)
			{
				double x0 = ((Point)values[0]).X;
				double y0 = ((Point)values[0]).Y;

				double x1 = ((Point)values[1]).X;
				double y1 = ((Point)values[1]).Y;

				double theta = Math.Atan2(y1 - y0, x1 - x0);
				double sint = Math.Sin(theta);
				double cost = Math.Cos(theta);

				double headWidth = 25;
				double headHeight = 0;

				Point pt3 = new Point(
					x0 + (headWidth * cost - headHeight * sint),
					y0 + (headWidth * sint + headHeight * cost));

				return pt3;

				//return new Point(x2, y2);
			}

			return null;
			throw new NotImplementedException();
		}

		public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
		{
			throw new NotImplementedException();
		}

	}
}
